package com.ktkj.init.vo;

import com.ktkj.init.constant.CharConstant;
import com.ktkj.init.utils.IdentitiesUtils;
import lombok.Data;
import org.apache.commons.compress.utils.Lists;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Data
public class TreeDataVo {
    private String id;
    private Long tableId;
    private String label;
    private Integer level;
    private List<TreeDataVo> children = Lists.newArrayList();
    private int childrenSize;

    public TreeDataVo() {
    }

    public TreeDataVo(Long tableId, String label,Integer level) {
        this.id = IdentitiesUtils.uuid2() + CharConstant.SPLIT_HG + System.currentTimeMillis();
        this.tableId = tableId;
        this.label = label;
        this.level = level;
    }

    public void setChildren(List<TreeDataVo> children) {
        this.children = children;
        this.childrenSize = CollectionUtils.isEmpty(children) ? 0 : children.size();
    }
}
